package com.hz.ruoyistorage.api;

import com.hz.ruoyistorage.domain.mypojo.LgSubColdSome;
import com.hz.ruoyistorage.service.LgColdStorageService;
import com.hz.ruoyistorage.service.LgSubColdSomeService;
import com.hz.ruoyistorage.utils.ResultJSON;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Author gj
 * @Date 2025/3/8 16:28
 * @注释
 */
//给罗二款的api
@RestController
@RequestMapping("/api3")
public class SubColdCameraApi {
    @Autowired
    private LgSubColdSomeService lgSubColdSomeService;
    @Autowired
    private LgColdStorageService lgColdStorageService;

    @PostMapping("/getSubAndCamera")
    public ResultJSON getSubAndCamera(@RequestBody Map<String, Object> query)
    {
        //获取当前页
        Integer pageNum = Integer.parseInt(query.get("pageNum").toString());
        //获取每页条数
        Integer pageSize = Integer.parseInt(query.get("pageSize").toString());
        query.put("firstNum",(pageNum-1)*pageSize);
        query.put("secondNum",pageSize);
        if(query.get("parentId")!=null){
            String parentId = query.get("parentId").toString();
            System.out.println("======================================"+parentId);
        }
        //算钱
        List<LgSubColdSome> lgSubColdSomes = lgSubColdSomeService.updateDailyPrice(lgSubColdSomeService.getSubAndCamera(query));
        return ResultJSON.success(lgSubColdSomes);
    }


    @PostMapping("/getSubAndMachine")
    public ResultJSON getSubAndMachine(@RequestBody Map<String, Object> query)
    {
        //获取当前页
        Integer pageNum = Integer.parseInt(query.get("pageNum").toString());
        //获取每页条数
        Integer pageSize = Integer.parseInt(query.get("pageSize").toString());
        query.put("firstNum",(pageNum-1)*pageSize);
        query.put("secondNum",pageSize);
        if(query.get("parentId")!=null){
            String parentId = query.get("parentId").toString();
            System.out.println("======================================"+parentId);
        }
        //算钱
        List<LgSubColdSome> lgSubColdSomes = lgSubColdSomeService.updateDailyPrice(lgSubColdSomeService.getSubAndMachine(query));
        return ResultJSON.success(lgSubColdSomes);
    }




    @GetMapping("/getColdAndMechine")
    public ResultJSON getAll(String coldName,
                             String coldDescript,
                             String address,
                             String area1,
                             String area2,
                             String totalVolume1,
                             String totalVolume2,
                             Integer status,
                             Integer managerId,
                             Integer pageNum,
                             Integer pageSize){
        System.out.println("status"+status);
        Integer firstNum = (pageNum-1)*pageSize;
        Integer secondNum = pageSize;

        //完成分页
        return ResultJSON.success(lgColdStorageService.getColdAndMachine(coldName, coldDescript, address, area1,
                area2, totalVolume1, totalVolume2, status,managerId, firstNum, secondNum));
    }
}
